package com.youthHostel.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

public class LoginInterceptor implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
			String uname = (String)request.getSession().getAttribute("user");
			System.out.println(uname);
			if(uname == null) {
				response.sendRedirect(request.getContextPath()+"/login.jsp");
				return false;
			}else {
				return true;
			}
	}
	
	

}
